The program approves the purchase of a sweater only if it is cheaper than $20.00.
PRINT "How much is this sweater" INPUT COST ' IF COST < 20 THEN PRINT "Buy the Sweater" ' true branch END IF ' PRINT "done" END
Since only sweaters LESS THAN $20.00 could be purchased, the correct relational symbol is < .
Often there are several options that might be included in a purchase. Each one might be accepted or rejected. Say that you are in the market for a new car:
You have decided to buy a new sports car. The base price is $20,000. There are two options:
- pin strips --- $250
- anti-lock brakes --- $800
The price of the car will be the base price plus the price of the options you have picked. Write a program that calculates the final price of the car.
Here is a incomplete version:
LET PRICE = 20000 ' PRINT "Type 1 if you want pin stripes, 0 if not" INPUT STRIPES ' IF ____________ THEN LET PRICE = PRICE + 250 END IF ' PRINT "Type 1 if you want anti-lock brakes, 0 if not" INPUT BRAKES ' IF ____________ THEN LET PRICE = PRICE + 800 END IF ' PRINT "Final price:", PRICE END
Fill in the two blanks to complete the program.